package main

import (
	"fmt"
	"strconv"
)

func main() {
	//字符串 转化 int  strconv
	var str string = "16"
	fmt.Println(str + "2")
	result, _ := strconv.ParseInt(str, 10, 64)

	fmt.Println(result)
	fmt.Println(result + 2)

	res, _ := strconv.Atoi(str)
	fmt.Println(res)
	fmt.Printf("%T", res) //默认十进制
	fmt.Println()

	//把int类型转化为字符串
	var i int = 1000
	//formatInt := strconv.FormatInt(int64(i), 10)
	//fmt.Println(formatInt)
	//fmt.Printf("%T",formatInt)
	itoa := strconv.Itoa(i)
	fmt.Println(itoa)
	fmt.Printf("%T", itoa) //默认十进制

	//浮点转化为字符串
	var f float64 = 1.5
	float := strconv.FormatFloat(f, 'f', 2, 64)
	fmt.Println(float)
	fmt.Printf("%T", float)

	//字符串 -》 转化为浮点
	//strconv.ParseFloat(s,64)
}
